<template>
    <div>
        <p style="font-weight: bold" class="interfaceHead"><i class="el-icon-s-promotion"></i>申请行政许可</p>
        <el-divider></el-divider>
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="单位名称" style="width: 40%">
                <el-input placeholder="请输入注册企业单位名称" v-model="form.companyName"></el-input>
            </el-form-item>
            <el-form-item label="选择地区"  style="width: 40%">
                <el-input placeholder="请输入地区名称,例如：XX省XX市" v-model="form.address"></el-input>
            </el-form-item>
            <el-form-item label="法人信息" >
                <el-input style="width: 15%" placeholder="请输入法人名称" v-model="form.corpName"></el-input>
                <el-input style="width: 40%" placeholder="请输入身份证号" v-model="form.corpNo"></el-input>
            </el-form-item>
            <el-form-item label="单位类别" style="width:15%">
                <el-select v-model="form.type" placeholder="请选择">
                    <el-option
                            v-for="item in actions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="经营范围" style="width:15%">
                <el-select v-model="form.scope" placeholder="请选择">
                    <el-option
                            v-for="item in activities"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="职工人数" style="width:30%">
                <el-input placeholder="请输入职工人数" v-model="form.payroll"></el-input>
            </el-form-item>
            <el-form-item label="营业面积" style="width:30%">
                <el-input placeholder="请输入营业面积" v-model="form.area"></el-input>
            </el-form-item>
            <el-form-item >
                营业执照上传
                <el-upload
                        action="/company/uploadFile"
                        ref="uploadDemo"
                        list-type="picture-card"
                        :auto-upload="false"
                        :headers="headers"
                        multiple="false">
                    <i slot="default" class="el-icon-plus"></i>
                    <div slot="file" slot-scope="{file}">
                        <img
                                class="el-upload-list__item-thumbnail"
                                :src="file.url" alt="">
                    </div>
                </el-upload>

            </el-form-item>
            `<el-button type="primary" @click="submmitUser" style="margin-left: 500px">提交</el-button>
        </el-form>
    </div>
</template>

<script>
    export default {
        name: "UserApply",
        data() {
            return {
                form: {
                    companyName: '',
                    corpName: '',
                    corpNo: '',
                    payroll: '',
                    area: '',
                    address: '',
                    type: '',
                    url:'',
                    scope:'',

                },
                activities: [{
                    value: '餐饮',
                    label: '餐饮'
                }, {
                    value: '医疗器械',
                    label: '医疗器械'
                }, {
                    value: '诊所',
                    label: '诊所'
                }],
                scope: [],


                actions: [{
                    value: '外企',
                    label: '外企'
                }, {
                    value: '国企',
                    label: '国企'
                }, {
                    value: '个人企业',
                    label: '个人企业'
                }],
                type: [],
            }
        },
        computed: {
            headers: function () {
                return {
                    "Authorization": `${localStorage.getItem('token')}`
                }
            }
        },
        methods: {
            submmitUser() {
                this.$refs.form.validate((valid) => {
                    if (valid) {
                        const _this = this;
                        this.postRequest('/company/upload', this.form).then(resp => {
                            if (resp) {
                                _this.$refs.uploadDemo.submit();
                                if (resp) {
                                console.log(resp)
                                this.$router.replace('/user/userprogress');
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                }
                            }
                        })

                    } else {
                        this.$message.error('提交失败！');
                        return false;
                    }
                });
            },

        }
    }

</script>

<style scoped>


</style>